import { Component, OnInit, ViewChild } from '@angular/core';
import { TabsetComponent } from 'ngx-bootstrap';
import {Location} from '@angular/common'
import { Router } from '@angular/router';
import { GetDataService } from './../../../../share/services/get-data.service';

@Component({
  selector: 'app-alternator-overview',
  templateUrl: './alternator-overview.component.html',
  styleUrls: ['./alternator-overview.component.css']
})
export class AlternatorOverviewComponent implements OnInit {

  constructor(
    private router: Router,
    private location: Location,
    private getDataService:GetDataService
  ) { }
  public fdjParam;
  public data1 = [{
    name: '平均温升',
    data: [4.3, 5.1, 4.3, 5.2, 5.4, 4.7, 3.5, 4.1, 5.6, 4.4, 4.9, 4.1]
  }, {
    name: '最大温差',
    data: [0.4, 0.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.0, 0.3, 0.0]
  },{
    name: '温度变化率',
    data: [0.3, 0.9, 1.0, 3.0, 5.0, 7.0, 3.0, 4.0, 0.1, 6.0, 0.3, 0.0]
  }];
  public data2 = [{
    name: '空冷器进出口水温差',
    data: [4.3, 5.1, 4.3, 5.2, 5.4, 4.7, 3.5, 4.1, 5.6, 4.4, 4.9, 4.1]
  }, {
    name: '冷风与空冷器进出口水温差',
    data: [0.4, 0.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.0, 0.3, 0.0]
  }];
  ngOnInit() {
    this.getDataService.getFdjParam().subscribe(
      data => {
        this.fdjParam = data;
        console.log(data);
      }
    )
  }

  navigator(num:number) {
    if(num === 0) {
      this.router.navigate(['/pages/performance-analysis/spider-overview/2'])
    }else{
      this.router.navigate(['/pages/performance-analysis/scatter-overview/2'])
    }
  }
  draw(num) {
    let data = [
      [{
        name: '平均温升',
        data: [4.3, 5.1, 4.3, 5.2, 5.4, 4.7, 3.5, 4.1, 5.6, 4.4, 4.9, 4.1]
      }, {
        name: '最大温差',
        data: [0.4, 0.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.0, 0.3, 0.0]
      },{
        name: '温度变化率',
        data: [0.3, 0.9, 1.0, 3.0, 5.0, 7.0, 3.0, 4.0, 0.1, 6.0, 0.3, 0.0]
      }],
      [{
        name: '平均温升',
        data: [0.4, 0.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.0, 0.3, 0.0]
      }, {
        name: '最大温差',
        data: [4.3, 5.1, 4.3, 5.2, 5.4, 4.7, 3.5, 4.1, 5.6, 4.4, 4.9, 4.1]
      },{
        name: '温度变化率',
        data: [0.3, 0.9, 1.0, 3.0, 5.0, 7.0, 3.0, 4.0, 0.1, 6.0, 0.3, 0.0]
      }],
      [{
        name: '平均温升',
        data: [0, 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 0.0, 0.3, 0.0]
      }, {
        name: '最大温差',
        data: [4.3, 5.1, 4.3, 5.2, 5.4, 4.7, 3.5, 4.1, 5.6, 4.4, 4.9, 4.1]
      },{
        name: '温度变化率',
        data: [0.3, 0.9, 1.0, 3.0, 5.0, 7.0, 3.0, 4.0, 0.1, 6.0, 0.3, 0.0]
      }],
      [{
        name: '平均温升',
        data: [0.4, 0.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.0, 0.3, 0.0]
      }, {
        name: '最大温差',
        data: [0, 0, 0, 0, 0, 4.7, 3.5, 4.1, 5.6, 4.4, 4.9, 4.1]
      },{
        name: '温度变化率',
        data: [0.3, 0.9, 1.0, 3.0, 5.0, 7.0, 3.0, 4.0, 0.1, 6.0, 0.3, 0.0]
      }],
      [{
        name: '平均温升',
        data: [0.4, 0.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.0, 0.3, 0.0]
      }, {
        name: '最大温差',
        data: [4.3, 5.1, 4.3, 5.2, 5.4, 4.7, 3.5, 4.1, 5.6, 4.4, 4.9, 4.1]
      },{
        name: '温度变化率',
        data: [0, 0, 0, 0, 0, 7.0, 3.0, 4.0, 0.1, 6.0, 0.3, 0.0]
      }],
    ]
    this.data1 = data[num];
  }

  public goBack(flag?:boolean){
    if(flag){
      this.location.back()
    }
    else {
      this.router.navigate(['/pages/home'])
    }
  }
}
